home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 10, No. 03 (1989-03)(MicroSPARC)(Side A).zip
/
Nibble Volume 10, No. 03 (1989-03)(MicroSPARC)(Side A).po
/
LINE.MAGICIAN.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
4KB
|
138 lines
*
* LINE.MAGICIAN Source Code
* BY DAVID HARRIS
* COPYRIGHT (C) 1989
* MICROSPARC, INC.
* CONCORD, MA 01742
*
ORG $8000
PROGRAM EQU $67 ; PROGRAM START POINTER
LINE EQU $FB ; POINTER TO PRESENT LINE
NEXT EQU $FD ; POINTER TO NEXT LINE
REM EQU #$B2 ; TOKEN FOR REM
* Main Entry Point
MAIN LDA PROGRAM ; GET START LSB
STA LINE
LDA PROGRAM+1 ; GET START MSB
STA LINE+1
LOOP LDY #$00 ; INDIRECT INDEXING
CLC
LDA (LINE),Y ; LOW POINTER TO NEXT LINE
STA NEXT
BNE :1 ; NOT A NULL POINTER
SEC ; POSSIBLE NULL POINTER
:1 INY
LDA (LINE),Y ; HIGH POINTER TO NEXT LINE
STA NEXT+1
BNE GOOD ; NOT A NULL POINTER
BCC GOOD ; NOT A NULL POINTER
RTS ; END OF PROGRAM
GOOD INY
INY ; SKIP LSB OF LINENUM
LDA (LINE),Y ; MSB OF LINENUM
CMP #$F7 ; GREATER THAN 63232
BLT NOSHIFT ; NO--NEXT LINE
CMP #$FA ; GREATER THAN 63999
BGE NOSHIFT
CLC
ADC #$04 ; MOVE ABOVE 63999
STA (LINE),Y ; AND REPLACE
INY
LDA (LINE),Y ; GET NEXT BYTE
CMP #REM ; IS IT A REM
BNE NOSHIFT ; NO, SKIP TO NEXT LINE
TYA
CLC
ADC LINE ; SET LINE PTR TO POSITION
STA LINE
LDA #$00
ADC LINE+1
STA LINE+1
LDY #$00
CHANGE LDA (LINE),Y ; CHANGE ` FOR BACKSPACE
BEQ NOSHIFT ; DONE WITH LINE
CMP #$60 ; IS IT A `
BNE :1 ; NO
LDA #$08 ; BACKSPACE
STA (LINE),Y ; REPLACE `
:1 INY ; NEXT BYTE
CLC
BCC CHANGE ; ALWAYS
NOSHIFT LDA NEXT ; NEXT LINE
STA LINE
LDA NEXT+1
STA LINE+1
CLC
BCC LOOP ; ALWAYS
* Undo Entry Point
UNDO LDA PROGRAM ; GET START LSB
STA LINE
LDA PROGRAM+1 ; GET START MSB
STA LINE+1
LOOP2 LDY #$00 ; INDIRECT INDEXING
CLC
LDA (LINE),Y ; LOW POINTER TO NEXT LINE
STA NEXT
BNE :1 ; NOT A NULL POINTER
SEC ; POSSIBLE NULL POINTER
:1 INY
LDA (LINE),Y ; HIGH POINTER TO NEXT LINE
STA NEXT+1
BNE GOOD2 ; NOT A NULL POINTER
BCC GOOD2 ; NOT A NULL POINTER
RTS ; END OF PROGRAM
GOOD2 INY
INY ; SKIP LSB OF LINENUM
LDA (LINE),Y ; MSB OF LINENUM
CMP #$FA ; LESS THAN 63999
BLT NOSHIFT2
SEC
SBC #$04 ; MOVE BELOW 63999
STA (LINE),Y ; AND REPLACE
INY
LDA (LINE),Y ; GET NEXT BYTE
CMP #REM ; IS IS A REM
BNE NOSHIFT2 ; NO, SKIP TO NEXT LINE
TYA
CLC
ADC LINE ; SET LINE POINTER TO AFTER REM
STA LINE
LDA #$00
ADC LINE+1
STA LINE+1
LDY #$00
CHANGE2 LDA (LINE),Y ; CHANGE BACKSPACE FOR `
BEQ NOSHIFT2 ; DONE WITH LINE
CMP #$08 ; IS IT A BACKSPACE
BNE :1
LDA #$60 ; `
STA (LINE),Y
:1 INY ; NEXT BYTE
CLC
BCC CHANGE2 ; ALWAYS
NOSHIFT2 LDA NEXT ; NEXT LINE
STA LINE
LDA NEXT+1
STA LINE+1
CLC
BCC LOOP2 ; ALWAYS
LST OFF